package duhosdebuggolok;

import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class LionAntPainter  implements Painter{
	
	private static BufferedImage lionAntImage0 = null;
	private static BufferedImage lionAntImage1 = null;
	private static BufferedImage lionAntImage2 = null;
	private LionAnt lionAnt;
	
	public LionAntPainter(LionAnt la) {
		lionAnt = la;
		if (lionAntImage0 == null)
			loadImage();
	}
	
	private static void loadImage() {
		try {
			lionAntImage0 = ImageIO.read(new File(System.getProperty("user.dir")+"\\resources\\hangyaleso.png"));
			lionAntImage1 = ImageIO.read(new File(System.getProperty("user.dir")+"\\resources\\hangyaleso3.png"));
			lionAntImage2 = ImageIO.read(new File(System.getProperty("user.dir")+"\\resources\\hangyaleso5.png"));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public boolean paint(Graphics2D g){
		Point coord = lionAnt.getCoord();
		int radius = lionAnt.getRadius();
		double scale = -0.5;
		AffineTransform affineTransform = new AffineTransform();
		Point c = GamePanel.calculate(coord);
		affineTransform.translate((c.x-10*(radius-1)), (c.y-10*(radius-1)));
		affineTransform.scale(2*radius+scale, 2*radius+scale);
		//affineTransform.rotate(Math.toRadians(45), 5, 5);
		switch (radius) {
		case 0: g.drawImage(lionAntImage0, c.x, c.y+3, null);
				break;
		case 1: g.drawImage(lionAntImage1, c.x-30, c.y-23, null);
				break;
		case 2: g.drawImage(lionAntImage2, c.x-60, c.y-50, null);
				break;
		}
		return true;
	}
}
